let nums = [1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 5, 5, 5, 8, 44]
function fn (nums) {
  let l = 0
  for (let i = 1; i < nums.length; i++) {
    if (nums[l] !== nums[i]) {
      l++
      nums[l] = nums[i]
    }
  }
  return l + 1
}

fn(nums)

function maxProfit (prices) {
  let profit = 0
  for (let i = 0; i < prices.length; i++) {
    if (prices[i + 1] - prices[i] > 0) {
      profit += prices[i + 1] - prices[i]
    }
  }
  return profit
}

function rotate (nums, k) {
  for (let i = 0; i < k; i++) {
    nums.unshift(nums.length)
  }
  console.log(nums)
  return nums.splice(0, nums.length - 1 - k)
}
let a = rotate([1, 2, 3, 4, 5, 6, 7], 3)
console.log(a)